<%@ Application Language="C#" %>
<%@ Import Namespace="Friso.Business" %>
<%@ Import Namespace="Friso.Entities" %>
<%@ Import Namespace="FetCo.Framework" %>
<%@ Import Namespace="Friso.Data" %>

<script RunAt="server">

    int count = 0;
    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        Application["CountVistor"] = count;
    }

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started
        Session["Order"] = FetCo.Framework.OrderDirection.DESC;
        Session["LanguageSelected"] = 0;
        Session["role"] = int.MinValue;
        Application.Lock();
        // Code that runs when a new session is started
        count = (int)Application["CountVistor"];
        count = count + 1;
        Application["CountVistor"] = count;
        Online _dm = OnlineService.GetOnline(1);
        _dm.Visits = _dm.Visits + 1;
        OnlineService.UpdateOnline(_dm);
    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.
        Session["Order"] = null;
        Session["LanguageSelected"] = null;
        Application.Lock();
        count = (int)Application["CountVistor"];
        count = count - 1;
        Application["CountVistor"] = count;
        Application.UnLock();
    }
       
</script>

